package com.sr.demo.security.nuouser.controller;

import cn.hutool.core.util.StrUtil;
import com.sr.demo.response.NuoResult;
import com.sr.demo.response.NuoSuccessStatus;
import com.sr.demo.security.nuouser.dto.NuoUserDTO;
import com.sr.demo.security.nuouser.service.NuoUserService;
import com.sr.demo.security.password.NuoPasswordEncoder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


/**
 * 用户表(NuoUser)表控制层
 *
 * @author liushuai
 * @since 2021-02-13 22:10:02
 */
@RestController
@RequestMapping("api/nuoUser")
@Api(tags="用户表")
public class NuoUserController {
    @Autowired
    private NuoUserService nuoUserService;

    /**
     * 保存用户信息
     * @Author: liushuai
     * @Date: 2021/2/13 22:20
     * @param : * @param nuoUserDTO
     * @return :com.sr.demo.response.NuoResult
     **/
    @PreAuthorize("hasAuthority('admin')")
    @ApiOperation(value = "保存用户" ,  notes="保存用户")
    @RequestMapping(value="/saveUser",method= RequestMethod.POST)
    public NuoResult saveUser(@RequestBody NuoUserDTO nuoUserDTO){
        nuoUserService.saveUser(nuoUserDTO);
        return NuoResult.buildResponse(NuoSuccessStatus.SAVE_SUCCESS);
    }



}